//
//  MeHeaderCollectionReusableView.m
//  高仿萝卜书摘
//
//  Created by 谢俊逸 on 2016/11/25.
//  Copyright © 2016年 谢俊逸. All rights reserved.
//

#import "MeHeaderCollectionReusableView.h"
#import "XJYHeader.h"

@interface MeHeaderCollectionReusableView (){
    BOOL Downward;
}

@end

@implementation MeHeaderCollectionReusableView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    //方向
    Downward = YES;
    //背景颜色
    self.backgroundColor = [UIColor whiteColor];
    for (UIView *view in self.subviews) {
        view.tintColor = ColorWithRGBA(151, 63, 63, 1);
        if ([view isKindOfClass:[UILabel class]]) {
            UILabel *label = (UILabel *)view;
            label.textColor = ColorWithRGBA(151, 63, 63, 1);
            label.font = [UIFont systemFontOfSize:14];
        }
    }
    [self setupButton];
    
}

- (void)setupButton{
    [_filtrateButton addTarget:self action:@selector(filtrateButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}



#pragma mark ButtonClicked

- (void)filtrateButtonClicked:(UIButton *)button{
    Downward = !Downward;
    if (Downward == NO) {
        _filtrateImageView.image = [UIImage imageNamed:@"UpwardIcon"];
    }else{
        _filtrateImageView.image = [UIImage imageNamed:@"DownwardIcon"];
    }
    
    UICollectionView *collectionView = (UICollectionView *)self.superview;
    
    [UIView animateWithDuration:0.5 animations:^{
        collectionView.contentOffset = CGPointMake(0, 0);
        //[collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
    }];


    
    
}
@end
